﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using Model;
namespace Model
{
    public static class ModelBuilderExtensions
    {
        public static void Seed(this ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Role>().HasData(
                new Role {
                    Role_ID = 1,
                    Role_Name = "总经理",
                    remarks = "无"
                },
                 new Role
                 {
                     Role_ID = 2,
                     Role_Name = "部门经理",
                     remarks = "无"
                 },
                  new Role
                  {
                      Role_ID = 3,
                      Role_Name = "总监",
                      remarks = "无"
                  });
            modelBuilder.Entity<Personnel>().HasData(
                new Personnel {
                    staff_ID = 1,
                    staff_NAME = "陈俊华",
                    staff_CODE = "GH0001",
                    staff_alias = "无",
                    username = "chenjunhua",
                    password = MD5Helper.MD5Encrypt32("123456"),
                    email = "315154751@qq.com",
                    home_tel = "18746729341",
                    Address = "湖南省长沙市岳麓区",
                    State_ID = 1,
                    certificates = "4301209392139381",
                    sex = "男",
                    Entry = "2020-12-20",
                    Job_ID = 1,
                    Role_ID = 1,
                    remarks = "无"
                },
                new Personnel
                {
                    staff_ID = 2,
                    staff_NAME = "单松华",
                    staff_CODE = "GH0002",
                    username = "dansohua",
                    password = MD5Helper.MD5Encrypt32("123456"),
                    email = "66781919@qq.com",
                    home_tel = "19736729341",
                    Address = "湖南省长沙市芙蓉区",
                    staff_alias = "无",
                    State_ID = 1,
                    certificates = "4011203434339381",
                    sex = "男",
                    Entry = "2020-10-10",
                    Job_ID =2,
                    Role_ID = 2,
                    remarks = "无"
                }
                );
            modelBuilder.Entity<Position>().HasData(
                    new Position {
                        Job_ID = 1,
                        Job_Name = "总经理",
                        Depar_ID = 1,
                        state_ID = 1,
                        remarks = "无",
                        email = "3982343343@qq.com"
                    },
                     new Position
                     {
                         Job_ID = 2,
                         Job_Name = "部门经理",
                         Depar_ID = 1,
                         state_ID = 1,
                         remarks = "无",
                         email = "278317819@qq.com"
                     }
                );
            modelBuilder.Entity<Department>().HasData(
                new Department
                {
                    Depar_ID = 1,
                    Depar_NAME = "开发部",
                    Depar_tel = "1892737267",
                    reamkers = "负责公司的项目开发"
                },
                new Department
                {
                    Depar_ID = 2,
                    Depar_NAME = "人事部",
                    Depar_tel = "179238397267",
                    reamkers = "负责公司的人才招聘"
                }
                );
            modelBuilder.Entity<Tstate>().HasData(
                    new Tstate {
                        State_ID = 1,
                        State_Name = "在职"
                    },
                    new Tstate
                    {
                        State_ID = 2,
                        State_Name = "离职"
                    }
                );
            modelBuilder.Entity<Jurisdiction>().HasData(
                new Jurisdiction { 
                    Power_ID=1,
                    Power_Name="人员管理",
                    route="/System/Organization",
                    Jid=1
                },
                new Jurisdiction
                {
                    Power_ID = 2,
                    Power_Name = "职位管理",
                    route = "/System/Position",
                    Jid = 1
                },
                new Jurisdiction
                {
                    Power_ID = 3,
                    Power_Name = "部门管理",
                    route = "/System/Department",
                    Jid = 1
                },
                new Jurisdiction
                {
                    Power_ID = 4,
                    Power_Name = "角色管理",
                    route = "/System/Role",
                    Jid = 1
                },
                new Jurisdiction
                {
                    Power_ID = 5,
                    Power_Name = "权限管理",
                    route = "/System/Organization",
                    Jid = 1
                }
                );
            modelBuilder.Entity<RState>().HasData(
                    new RState { 
                        Sid=1,
                        Sname="启用"
                    },
                    new RState
                    {
                        Sid = 2,
                        Sname = "禁用"
                    }
                );
            modelBuilder.Entity<JState>().HasData(
                    new JState
                    {
                        Jid = 1,
                        Jname = "启用"
                    },
                    new JState
                    {
                        Jid = 2,
                        Jname = "禁用"
                    }
                );
            modelBuilder.Entity<Rights>().HasData(
                    new Rights
                    {
                        rid=1,
                        Role_ID= 1,
                        Power_ID=1,
                        Sid = 1,
                    },
                    new Rights
                    {
                        rid = 2,
                        Role_ID = 1,
                        Power_ID = 2,
                        Sid = 1
                    },
                    new Rights
                    {
                        rid = 3,
                        Role_ID = 1,
                        Power_ID = 3,
                        Sid = 1
                    },
                    new Rights
                    {
                        rid = 4,
                        Role_ID = 1,
                        Power_ID = 4,
                        Sid = 1
                    }
                );
            modelBuilder.Entity<Astate>().HasData(
                new Astate
                {
                    Aid = 1,
                    AName="待审核"
                },
                new Astate
                {
                    Aid=2,
                    AName="已审核"
                }
                );
            modelBuilder.Entity<Leave_type>().HasData(
                    new Leave_type
                    {
                        Lid = 1,
                        TypeName = "家里有事"
                    },
                    new Leave_type
                    {
                        Lid = 2,
                        TypeName = "生病"
                    },
                    new Leave_type
                    {
                        Lid = 3,
                        TypeName = "亲戚结婚"
                    },
                    new Leave_type
                    {
                        Lid = 4,
                        TypeName = "其他"
                    }
                );
        }
    }
}
